package com.devbobcorn.nekoration.client.rendering.items;

import java.util.List;

import com.devbobcorn.nekoration.client.rendering.entities.WallPaperRenderer;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.datafixers.util.Pair;

import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShieldItem;
import net.minecraft.tileentity.BannerPattern;
import net.minecraft.tileentity.BannerTileEntity;
import net.minecraft.util.math.vector.Vector3f;

public class WallPaperItemRenderer extends ItemStackTileEntityRenderer {
    @Override
    public void renderByItem(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
        boolean flag = stack.getTagElement("BlockEntityTag") != null;
        matrixStack.pushPose();
        //matrixStack.scale(0.5F, -0.36F, -0.42F);
        //matrixStack.translate(1.0D, -1.32D, 0.0D);
        matrixStack.mulPose(Vector3f.ZP.rotationDegrees(180.0F));
        matrixStack.mulPose(Vector3f.YP.rotationDegrees(180.0F));

        List<Pair<BannerPattern, DyeColor>> list = flag ? BannerTileEntity.createPatterns(ShieldItem.getColor(stack), BannerTileEntity.getItemPatterns(stack)) : WallPaperRenderer.getBlankPattern(DyeColor.WHITE);
        BannerTileEntityRenderer.renderPatterns(matrixStack, buffer, combinedLight, combinedOverlay, WallPaperRenderer.paperFull, ModelBakery.BANNER_BASE, true, list, false);

        matrixStack.popPose();
    }
}
